from .summoner import Summoner
from .champion import Warrior, Guard, Mage, Assassin, Rider
from .item import HealPotion, LuckyCoin, Item, Flag, Fan, Tripod, Bag, Sword, Shield, Lance, Bow, Helmet, Bandage, Horse, Knife, Cannon
from .warrior import DaQiao, HanXin, XiShi, YangYuhuan, BaiQi, WuZetian
from .guard import ZhenJi, SunCe, ZhouYu, ZhangLiang, HuaMulan, LiuBei, LuBan, DiaoChan, LiShuwen, LiuBang
from .mage import XiaoQiao, MiYue
from .rider import WeiQing, MengTian, QinLiangyu, YingZheng, SunQuan, LiangHongyu, XuFu, DaJi
from .assassin import JingKe, Dragon
from typing import Dict, Any, Optional


class BasicSummoner(Summoner):
    """基础召唤师"""
    
    def __init__(self):
        super().__init__(
            card_id="basic_summoner",
            name="Basic Summoner",
            image_path="basic_summoner.jpg",
            description="Summoner: Basic summoner with 20 HP",
            hp=20
        )


class TestWarrior(Warrior):
    """测试战士"""
    
    def __init__(self):
        super().__init__(
            card_id="test_warrior",
            name="Test Warrior",
            image_path="test_warrior.jpg",
            description="Warrior: No special abilities",
            cost=3,
            attack=2,
            hp=3
        )


class TestGuard(Guard):
    """测试守卫"""
    
    def __init__(self):
        super().__init__(
            card_id="test_guard",
            name="Test Guard",
            image_path="test_guard.jpg",
            description="Guard: Must target a unit to guard when summoned",
            cost=2,
            attack=1,
            hp=4
        )


class TestMage(Mage):
    """测试法师"""
    
    def __init__(self):
        super().__init__(
            card_id="test_mage",
            name="Test Mage",
            image_path="test_mage.jpg",
            description="Mage: Does not take counter damage when attacking",
            cost=4,
            attack=3,
            hp=2
        )


class TestAssassin(Assassin):
    """测试刺客"""
    
    def __init__(self):
        super().__init__(
            card_id="test_assassin",
            name="Test Assassin",
            image_path="test_assassin.jpg",
            description="Assassin: Hidden before first attack",
            cost=3,
            attack=3,
            hp=1
        )


class TestRider(Rider):
    """测试骑士"""
    
    def __init__(self):
        super().__init__(
            card_id="test_rider",
            name="Test Rider",
            image_path="test_rider.jpg",
            description="Rider: Can attack the turn it is summoned",
            cost=2,
            attack=2,
            hp=2
        )


class TestHealPotion(HealPotion):
    """测试治疗药水"""
    
    def __init__(self):
        super().__init__(
            card_id="heal_potion",
            name="Heal Potion",
            image_path="heal_potion.jpg",
            description="Item: Restore 3 HP to target friendly unit",
            cost=1
        )


class TestLuckyCoin(LuckyCoin):
    """测试幸运币"""
    
    def __init__(self):
        super().__init__(
            card_id="lucky_coin",
            name="Lucky Coin",
            image_path="lucky_coin.jpg",
            description="Item: Gain 1 extra PP this turn",
            cost=0
        )


# 测试卡牌类（保留在card_examples.py中）


# 卡牌注册表
CARD_REGISTRY = {
    "basic_summoner": BasicSummoner,
    "test_warrior": TestWarrior,
    "test_guard": TestGuard,
    "test_mage": TestMage,
    "test_assassin": TestAssassin,
    "test_rider": TestRider,
    "heal_potion": TestHealPotion,
    "lucky_coin": TestLuckyCoin,
    # 新英雄卡牌
    "wei_qing": WeiQing,
    "meng_tian": MengTian,
    "zhen_ji": ZhenJi,
    "da_qiao": DaQiao,
    "sun_ce": SunCe,
    "xiao_qiao": XiaoQiao,
    "zhou_yu": ZhouYu,
    "jing_ke": JingKe,
    "han_xin": HanXin,
    "mi_yue": MiYue,
    # 新道具卡牌
    "flag": Flag,
    "fan": Fan,
    # 新卡组英雄卡牌
    "xi_shi": XiShi,
    "zhang_liang": ZhangLiang,
    "qin_liangyu": QinLiangyu,
    "hua_mulan": HuaMulan,
    "wu_zetian": WuZetian,
    "liu_bei": LiuBei,
    "dragon": Dragon,
    "ying_zheng": YingZheng,
    # 新卡组道具卡牌
    "tripod": Tripod,
    "bag": Bag,
    "sword": Sword,
    # Character3卡牌
    "lu_ban": LuBan,
    "diao_chan": DiaoChan,
    "li_shuwen": LiShuwen,
    "liu_bang": LiuBang,
    "sun_quan": SunQuan,
    "shield": Shield,
    "lance": Lance,
    "bow": Bow,
    "helmet": Helmet,
    "bandage": Bandage,
    # Character4 卡牌
    "liang_hongyu": LiangHongyu,
    "xu_fu": XuFu,
    "da_ji": DaJi,
    "yang_yuhuan": YangYuhuan,
    "bai_qi": BaiQi,
    "horse": Horse,
    "knife": Knife,
    "cannon": Cannon,
}


def create_card(card_id: str):
    """根据卡牌ID创建卡牌实例"""
    if card_id not in CARD_REGISTRY:
        raise ValueError(f"Unknown card ID: {card_id}")
    
    card_class = CARD_REGISTRY[card_id]
    return card_class()
